﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity;
using PagedList;

namespace StoreManager.Models
{
    [Table("Products")]
    public class Product:BaseModel
    {
        [Key]
        [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
        public int ProductID { get; set; }

        [Required(ErrorMessage = MSG.REQUIRED)]
        [StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
        [DataType(DataType.Text)]
        [Display(Name = "Mã Sản Phẩm")]
        public string Code {get;set;}

        [Required(ErrorMessage = MSG.REQUIRED)]
        [StringLength(100)]
        [DataType(DataType.Text)]
        [Display(Name = "Tên Sản Phẩm")]
        public string Name { get; set; }

        [Required(ErrorMessage = MSG.REQUIRED)]
        [StringLength(50)]
        [Display(Name = "Loại Sản Phẩm")]
        public string Type { get; set; }

        [Required(ErrorMessage = MSG.REQUIRED)]
        [StringLength(50)]
        [Display(Name = "Kiểu Đóng Gói")]
        public string PackType { get; set; }

        [Display(Name = "Ghi chú")]
        [StringLength(300)]
        public string Description { get; set; }
    }

    //Basic Class for all model classes which map with tables in database
    public class BaseModel
    {
        public BaseModel()
        {
            CreatedBy = "Default";
            ModifiedBy = "Default";
            Created = System.DateTime.Now;
            LastModified = System.DateTime.Now;
        }
        [Required]
        [StringLength(50)]
        public string CreatedBy { get; set; }

        [Required]
        [StringLength(50)]
        public string ModifiedBy { get; set; }

        [Required]
        [DataType(DataType.DateTime)]
        public DateTime Created { get; set; }

        [Required]
        [DataType(DataType.DateTime)]
        public DateTime LastModified { get; set; }
    }

    /// <summary>
    /// Type of package map with database
    /// </summary>
    [Table("PackageTypes")]
    public class PackageType
    {
        public PackageType()
        {
            Code = "001";
            Name = "Hộp";
        }
        public PackageType(string acode, string aname)
        {
            Code = acode;
            Name = aname;
        }
        [Key]
        [Required]
        [StringLength(20)]
        public string Code { get; set; }

        [Required]
        [StringLength(100)]
        public string Name { get; set; }
    }
    [Table("ProductTypes")]
    public class ProductType
    {
        public ProductType()
        {
        }
        public ProductType(string acode, string aname)
        {
            Code = acode;
            Name = aname;
        }
        [Key]
        [Required]
        [StringLength(20)]
        public string Code { get; set; }

        [Required]
        [StringLength(100)]
        public string Name { get; set; }
    }

    [Table("ReferenceData")]
    public class SMCode
    {
        public SMCode()
        {
        }
        public SMCode(string acode, string aname)
        {
            Code = acode;
            Name = aname;
        }
        [Key]
        [Required]
        [StringLength(20)]
        public string Code { get; set; }

        [Required]
        [StringLength(100)]
        public string Name { get; set; }
        
        [Required]
        [StringLength(20)]
        public string GroupCode { get; set; }
    }
}